package com.goldenbean.test;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean
@RequestScoped
public class Ajax {
	
	Logger logger = Logger.getLogger(Ajax.class.toString());

	private User user = new User();
	
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Logger getLogger() {
		return logger;
	}

	public void setLogger(Logger logger) {
		this.logger = logger;
	}




	private String ajaxMsg;

	public String getAjaxMsg() {
		return ajaxMsg;
	}

	public void setAjaxMsg(String ajaxMsg) {
		this.ajaxMsg = ajaxMsg;
	}
	
	
	
	public void ajaxEvent(javax.faces.event.AjaxBehaviorEvent event)throws javax.faces.event.AbortProcessingException{
		
		logger.info(ajaxMsg);
	}
	
	

	public void selectEvent(javax.faces.event.AjaxBehaviorEvent event)throws javax.faces.event.AbortProcessingException{
		Map<String, User> userMap = new HashMap();
		
		User u1 = new User();
		u1.setUserName("zhangsan");
		u1.setAddress("江苏连云港");
		u1.setTel("0518--123132213");
		u1.setPassword("asdfjasdf");
		userMap.put("zhangsan", u1);
		
		User u2 = new User();
		u2.setUserName("lisi");
		u2.setAddress("江苏徐州");
		u2.setTel("0511--1asdfas");
		u2.setPassword("wwwww");
		userMap.put("lisi", u2);
		
		User u3 = new User();
		u3.setUserName("wangwu");
		u3.setAddress("北京");
		u3.setPassword("beijing");
		u3.setTel("010-asdfasdfsadf");
		userMap.put("wangwu", u3);
		
		
		user = userMap.get(user.getUserName());
		
		int a = 1/0;
	
	}
	
}



















